package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.bjesc_b2c.app.appraiset.R;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.DemandCarBean;

/**
 * Created by yidong on 2017/5/23.
 */

public class DemandCarAdapter extends CommonAdapter<DemandCarBean> {

    public DemandCarAdapter(Context context, int layoutId, List<DemandCarBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convertView(ViewHolder holder, DemandCarBean demandBean, int position) {
        if (demandBean.isCheck()){
            holder.setBackgroundRes(R.id.iv_selected,R.mipmap.ic_basic_checkbox_check);
            holder.setTextColor(R.id.tv_publish_time,R.color.color72aeff);
        }else {
            holder.setBackgroundRes(R.id.iv_selected,R.mipmap.ic_basic_checkbox_notcheck);
        }
        if (!TextUtils.isEmpty(demandBean.getImg_url())) {
            if (demandBean.getImg_url().contains("http")) {
                holder.setFrescoUrl(R.id.tv_car_photo, demandBean.getImg_url(), true);
            } else {
                holder.setFrescoFile(R.id.tv_car_photo, demandBean.getImg_url(), true);
            }
        }
        if (!TextUtils.isEmpty(demandBean.getBrand_name())) {
            holder.setText(R.id.tv_car_type, demandBean.getBrand_name() + " " + demandBean.getCarserie_name() +
                    " " + demandBean.getCarspec_name());
        }
        if (!TextUtils.isEmpty(demandBean.getOwner_price())) {
            holder.setText(R.id.tv_car_price, demandBean.getOwner_price()+"万");
        }
        if (!TextUtils.isEmpty(demandBean.getPublish_time())) {
            holder.setText(R.id.tv_publish_time, "发布 " + demandBean.getPublish_time());
        }
    }
}
